package  
{
        
        import mx.core.UIComponent;
        import flash.display.GradientType;
        import flash.display.SpreadMethod;
        import flash.display.InterpolationMethod;
        import flash.geom.Matrix;
        import mx.effects.Rotate;
        import flash.net.URLRequest;
    import flash.display.Sprite;
    import flash.display.BitmapData;
    import flash.display.Loader;
    import flash.net.URLRequest;
    import flash.events.Event;
    import flash.events.IOErrorEvent;
    import flash.geom.Matrix;
        import mx.controls.Alert;


        import flash.display.Loader;


        public class Pax  extends UIComponent
        {
                
            public function Pax() 
            {
                    
            }
            
                    
            public function set color(i: int): void {
                invalidateDisplayList(); 
            }
            

            private var ldr:Loader;
            public var paxid:String;
            
            
            override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
                    
                graphics.clear();
                
                var url:String = "http://hq.shockfish.com:8080/"+paxid+".jpg";//"file:///C:/wall/"+paxid+".jpg";
                //trace(url);
                ldr = new Loader();
                var urlReq:URLRequest = new URLRequest(url);
                ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, drawImage);
    			ldr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
                ldr.load(urlReq);

            }
                
                   
        

        private function drawImage(event:Event):void {

            var mySprite:Sprite = new Sprite();
            var myBitmap:BitmapData = new BitmapData(ldr.width, ldr.height, false);
  
            myBitmap.draw(ldr, new Matrix());
            
            var matrix:Matrix = new Matrix();
            //matrix.rotate(Math.PI/4);
            //mySprite.graphics.beginBitmapFill(myBitmap, matrix, true);
                        mySprite.graphics.beginBitmapFill(myBitmap);
            //mySprite.graphics.drawRect(100, 50, 200, 90);
                        mySprite.graphics.drawCircle(135  / 2, 180 / 2, 135 / 2);
            mySprite.graphics.endFill();
            
            addChild(mySprite);
        }
 
         private function ioErrorHandler(event:IOErrorEvent):void {
            //trace("Unable to load image: " );
        }

                
        }

}